package br.com.lazyprogrammer.social.infestit.localization.exception;

import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;

import br.com.lazyprogrammer.social.infestit.R;

public class GPSException extends Exception implements DialogInterface.OnClickListener {
	
	
	private static final long serialVersionUID = 5520093855338552550L;

	public GPSException() {
		super();
	}
	public GPSException(Context context,int messageResource) {
		super(context.getResources().getString(messageResource));
	}
	
	public GPSException(String detailMessage) {
		super(detailMessage);
	}
	
	public GPSException(Throwable throwable) {
		super(throwable);
	}
	
	public void showErrorDialog(Context context) {
		showErrorDialog(context,getMessage());
	}
	
	public void showErrorDialog(Context context, int messageResource) {
		showErrorDialog(context,context.getResources().getString(messageResource));
	}
	
	public void showErrorDialog(Context context, String message) {
		buildDialog(context, message).show();
	}
	
	protected Builder buildDialog(Context context, String message) {
		Builder builder = new Builder(context);
		builder.setTitle(R.string.title_exception);
		builder.setMessage(message);
		builder.setNegativeButton(android.R.string.ok, this);
		return builder;
	}

	@Override
	public void onClick(DialogInterface dialog, int which) {
		dialog.dismiss();
	}

}
